package com.music.controller;

import com.music.api.SmsApi;
import com.music.bean.Member;
import com.music.util.JsonResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制层
 */
@RestController
@RequestMapping("/user")
public class UserController {

	@Autowired
	private SmsApi smsApi;

	@RequestMapping("/save")
	public JsonResultUtil save(@RequestBody Member member) {

		if(member!=null && !StringUtils.hasLength(member.getPhone())) {
			JsonResultUtil jsonResultUtil = new JsonResultUtil();
			jsonResultUtil.setCode(201);
			jsonResultUtil.setMsg("参数为空");
			return jsonResultUtil;
		}

		JsonResultUtil jsonResultUtil = smsApi.sendTest(member.getPhone());

		if(jsonResultUtil.getCode() == 200) {


		}
 		return jsonResultUtil;
	}

}
